package com.ruoyi.business.buoy.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.business.buoy.domain.Buoy;
import com.ruoyi.business.buoy.service.IBuoyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 浮标管理Controller
 * 
 * @author 李国臻
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/system/buoy")
public class BuoyController extends BaseController
{
    @Autowired
    private IBuoyService buoyService;

    /**
     * 查询浮标管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:buoy:list')")
    @GetMapping("/list")
    public TableDataInfo list(Buoy buoy)
    {
        startPage();
        List<Buoy> list = buoyService.selectBuoyList(buoy);
        return getDataTable(list);
    }

    /**
     * 导出浮标管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:buoy:export')")
    @Log(title = "浮标管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Buoy buoy)
    {
        List<Buoy> list = buoyService.selectBuoyList(buoy);
        ExcelUtil<Buoy> util = new ExcelUtil<Buoy>(Buoy.class);
        util.exportExcel(response, list, "浮标管理数据");
    }

    /**
     * 获取浮标管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:buoy:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(buoyService.selectBuoyById(id));
    }

    /**
     * 新增浮标管理
     */
    @PreAuthorize("@ss.hasPermi('system:buoy:add')")
    @Log(title = "浮标管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Buoy buoy)
    {
        return toAjax(buoyService.insertBuoy(buoy));
    }

    /**
     * 修改浮标管理
     */
    @PreAuthorize("@ss.hasPermi('system:buoy:edit')")
    @Log(title = "浮标管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Buoy buoy)
    {
        return toAjax(buoyService.updateBuoy(buoy));
    }

    /**
     * 删除浮标管理
     */
    @PreAuthorize("@ss.hasPermi('system:buoy:remove')")
    @Log(title = "浮标管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(buoyService.deleteBuoyByIds(ids));
    }
}
